//
//  TTDatabaseRow.h
//  Tint
//
//  Created by Kevin Wu on 2/28/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Core/Core.h"
#import "Additions/Additions.h"


@class TTDatabaseResult;


@interface TTDatabaseRow : NSObject {
	NSMutableArray *_columnData;
	TTDatabaseResult *_databaseResult;
}

@property(nonatomic, readonly) NSMutableArray *columnData;
@property(nonatomic, readonly) TTDatabaseResult *databaseResult;


- (id)initWithDatabaseResult:(TTDatabaseResult *)result;


- (NSUInteger)columnIndexForName:(NSString *)columnName;


- (BOOL)boolForColumn:(NSString *)columnName;
- (BOOL)boolForColumnAtIndex:(NSUInteger)columnIndex;

- (int)intForColumn:(NSString *)columnName;
- (int)intForColumnAtIndex:(NSUInteger)columnIndex;

- (long long)longLongForColumn:(NSString *)columnName;
- (long long)longLongForColumnAtIndex:(NSUInteger)columnIndex;

- (double)doubleForColumn:(NSString *)columnName;
- (double)doubleForColumnAtIndex:(NSUInteger)columnIndex;

- (NSString *)stringForColumn:(NSString *)columnName;
- (NSString *)stringForColumnAtIndex:(NSUInteger)columnIndex;

- (NSDate *)dateForColumn:(NSString *)columnName;
- (NSDate *)dateForColumnIndex:(NSUInteger)columnIndex;

@end



@interface NSObject (DatabaseRow)

/*
 * Will load properties which appeared in row, and class should only use data 
 * type which supported, including:
 *   BOOL
 *   int
 *   long long
 *   double
 *   NSString *
 *   NSDate *
 */
- (void)loadValueFromDatabaseRow:(TTDatabaseRow *)row;

@end
